;
var book_cat_set_opt = {
    init:function () {
        this.eventBind();
    },
    eventBind:function () {
        $(".wrap_cat_set .save").click(function () {
            var btn_target = $(this);
            if( btn_target.hasClass( "disabled" ) ){
                common_ops.alert("正在处理，请不要重复提交~~");
                return;
            }

            var name_target = $(".wrap_cat_set input[name=name]");
            var name = name_target.val();

            if( name.length < 1 ){
                common_ops.tip("请输入合法的分类名",name_target);
            }

            btn_target.addClass("disabled");

            var data = {
                name:name,
                weight:$(".wrap_cat_set input[name=weight]").val(),
                id:$(".wrap_cat_set input[name=id]").val()
            }

            $.ajax({
                url:common_ops.buildWebUrl( "/book/cat_set" ),
                type:"POST",
                data:data,
                dataType:"json",
                success:function ( res ) {
                    btn_target.removeClass( "disabled" );
                    var callback = null;
                    if( res.code == 200 ){
                        callback = function () {
                            window.location.href = common_ops.buildWebUrl( "/book/cat" );
                        }
                    }
                    common_ops.alert(res.msg,callback);
                }
            });

        });
    }
}

$(document).ready(function () {
    book_cat_set_opt.init();
});